package com.unitechs.trap.write.webapi.service.impl;


import com.unitechs.trap.common.pojo.trap.entity.AlarmType;
import com.unitechs.trap.excel.service.IAlarmTypeExcelService;
import com.unitechs.trap.write.service.IAlarmTypeService;
import com.unitechs.trap.write.webapi.mapper.AlarmTypeMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@DubboService
@Slf4j
@Service
public class AlarmTypeServiceImpl implements IAlarmTypeService {

    @Autowired
    private AlarmTypeMapper alarmTypeMapper;
    @DubboReference(timeout = 1*1024*1024*1024)
    private IAlarmTypeExcelService alarmTypeExcelService;


    @Override
    public int insertAlarmTypes() {
        List<AlarmType> alarmTypes=alarmTypeExcelService.listAlarmType();
        if (alarmTypes==null||alarmTypes.isEmpty()){
            return 0;
        }
        int i = alarmTypeMapper.insertAlarmTypes(alarmTypes);
        return i;
    }
}
